package com.liu.io;

import java.net.URL;

public class GetResourceTest {
    public static void main(String[] args) {
        /**
         * 获取根路径和包路径
         */
        URL resource = GetResourceTest.class.getClassLoader().getResource("");
        String path = resource.getPath();
        //根路径：/java-base/out/production/01_base/
        System.out.println("根路径：" + path);

        URL resource1 = GetResourceTest.class.getResource("GetResourceTest.class");
        String path1 = resource1.getPath();
        //包路径：/java-base/out/production/01_base/com/liu/io/GetResourceTest.class
        System.out.println("包路径：" + path1);
    }
}

// 结果
